<?
$link           = $data['link'];
$count          = $data['count'];
$current        = $data['current'];
$neighbours     = (isset($data['neighboursArrows']) and $data['neighboursArrows']) ? true : false;
$number         = (isset($data['neighboursLimit'])) ? $data['neighboursLimit'] : 3;

$dott = '<span> ... </span>';

if($count > 1) {
	$result = '<ul class="block-pages">';
	$start  = (($start = $current - $number) > 1) ? $start : 1;
	$end    = (($end = $current + $number) < $count) ? $end : $count;
        
        if($neighbours) {
                $result .= ($current > 1) ? '<li><a href="'.$link . ($current-1).'/" title="Previous page">previous&nbsp<</a></li>' : '';
        }
	
	$result .= ($start >= 2) ? '<li><a href="'.$link . '1/">1</a></li>' : '';
	$result .= ($start > 2) ? $dott : '';
	for($i = $start; $i <= $end; $i++) {
		if($i == $current) {
			$result .= '<li class="active"><a href="'.$link . $i . '/">'.$i.'</a></li>';
		} else {
			$result .= '<li><a href="'.$link . $i . '/">'.$i.'</a></li>';
		}
	}
	$result .= ($end < $count - 1) ? $dott : '';
	$result .= ($end <= $count - 1) ? '<li><a href="'.$link . $count . '/">'.$count.'</a></li>' : '';
	
        if($neighbours) {
                $result .= ($current < $end) ? '<li><a href="'.$link .($current+1).'/" title="Next page">>&nbspnext</a></li>' : '';
        }
        
	$result .= '</ul>';
	echo $result;
}

?>